<?php

    $servername = "localhost";
    $username = "root";
    $password = "root123";
    $dbname = "oopdb";

    $conn = new mysqli($servername, $username, $password, $dbname);
    if ($conn->connect_error) {
        die("连接失败！".$conn->connect_error);
    }
    echo "连接成功！",PHP_EOL;

//    修改
//    $sql = "update fish set weight = weight + 1 where kind like '%鲑%' ";
//    $result = $conn->query($sql);
//    if($result){
//        echo "修改成功！",PHP_EOL;
//    }
//
//    $sql2 = "select * from fish where kind like '%鲑%'";
//    $result2 = $conn->query($sql2);
//    $row = $result2->fetch_all(MYSQLI_ASSOC);

//    echo "<pre>";
//    var_dump($row);

//删除
    $sql = "delete from fish where name like '这是%'";
    $result = $conn->query($sql);
    if($result){
        echo "删除成功！",PHP_EOL;
    }

    $sql2 = "select * from fish ";
    $result2 = $conn->query($sql2);
    $row2 = $result2->fetch_all(MYSQLI_ASSOC);

    echo "<pre>";
    var_dump($row2);

    $conn->close();
    
    
?>

